<!DOCTYPE html>
<html lang="en">
	<head>
    	<meta name="layout" content="main_mobile">
        <title>火堆</title>
        <script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
        <script type="text/javascript">
	    wx.config({
	 	    debug: false,  // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
	 	    appId: '${appid}', // 必填，公众号的唯一标识
	 	    timestamp: "${timestamp}", // 必填，生成签名的时间戳
	 	    nonceStr: '${nonceStr}', // 必填，生成签名的随机串
	 	    signature: '${signature}',// 必填，签名，见附录1
	 	    jsApiList: ['checkJsApi' , 'onMenuShareAppMessage' , 'onMenuShareTimeline']
	 	});

	 	wx.ready(function(){
	 		wx.checkJsApi({
	 		    jsApiList: ['onMenuShareAppMessage' , 
	 			 		    'onMenuShareTimeline'
	 		              ], // 需要检测的JS接口列表，所有JS接口列表见附录2,
	 		    success: function(res) {
	 		       //alert('wx.check: '+JSON.stringify(res));
	 		    }
	 		});
	 		//发送给朋友分享功能
	 		wx.onMenuShareAppMessage({
	 		    title: '${user?.nickname}邀请你进入火堆公益众筹，一起助力教育', // 分享标题
	 		    desc: '关注火堆，为教育发声！', // 分享描述
	 		    link: '${shareUrl}', // 分享链接
	 		    imgUrl: '${imgUrl}', // 分享图标
				trigger: function () {
				//alert("点击按钮");
				},
	 		    success: function () { 
	 		        // 用户确认分享后执行的回调函数
	 		        $('.wx-share-box').removeClass('show');
	 		    },
	 		    cancel: function () { 
	 		        // 用户取消分享后执行的回调函数
	 		    	$('.wx-share-box').removeClass('show');
	 		    }
	 		});

	 		//分享到朋友圈
	 		wx.onMenuShareTimeline({
	 		    title: '${user?.nickname}邀请你进入火堆公益众筹，一起助力教育', // 分享标题
	 		    link: '${shareUrl}', // 分享链接
	 		    imgUrl: '${imgUrl}',  // 分享图标
	 		    success: function () { 
	 		        // 用户确认分享后执行的回调函数
	 		    	$('.wx-share-box').removeClass('show');
	 		    },
	 		    cancel: function () { 
	 		        // 用户取消分享后执行的回调函数
	 		    	$('.wx-share-box').removeClass('show');
	 		    }	
	 		});
	 	});
	 	wx.error(function (res) {
			//alert('wx.error: '+JSON.stringify(res));
	    });

	 	function IsPC() 
	 	{ 
	 	var userAgentInfo = navigator.userAgent; 
	 	var Agents = new Array("Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"); 
	 	var flag = true; 
	 	for (var v = 0; v < Agents.length; v++) { 
	 	if (userAgentInfo.indexOf(Agents[v]) > 0) { flag = false; break; } 
	 	} 
	 	return flag; 
	 	}
	    
	</script>       
        <link rel="stylesheet" href="${resource(dir: 'css', file: 'index.css')}" type="text/css">
<style>
.t_num li {
    background: url('/scfire/images/number2_2x.jpg') no-repeat; 
    background-size: 16px 250px;
}   
</style>
</head>
<body>
	
   <%--<div class="ui-footer ui-footer-stable ui-btn-group ui-border-t">
        <a href="/scfire" class="active"><i class="i1"></i>首页</a>
        <g:link controller="project" action="fundPoolList"><i class="i2"></i>基金池</g:link>
        <g:link controller="project" action="start"><i class="i3"></i>发起项目</g:link>
        <g:link controller="user"  action="userCenter"><i class="i4"></i>我的</g:link>
        
        --%>
       <div class="ui-footer ui-footer-navi ui-btn-group ui-border-t">
        <a id="index" href="/scfire" class="active"><i class="i1"></i><div>首页</div></a>
        <a href="/scfire/project/fundPoolList"><i class="i2"></i><div>爱心池</div></a>
        <a id="project" href="/scfire/project/start"><i class="i3"></i><div>发起项目</div></a>
        <a id="center" href="/scfire/user/userCenter"><i class="i4"></i><div>个人中心</div></a>
    </div>
        
    </div>
	
	<div class="ui-container">
	    <input id="nums" type="hidden" value="${counts}">
	    <div  style="text-align: center; background-color: white; height: 20px; padding-top: 10px;font-size: 15px;padding-bottom:10px">
	                  <p style="display: initial;">已有</p>
			<span class="t_num">
			    <li></li>
				<li></li>
				<li></li>
				<li></li>
				<li></li>
				<li></li>
				<li></li>
			</span><p style="display: initial;">份爱心</p>
		</div>
		<div class="ui-slider">
	        <ul class="ui-slider-content">
	        	<g:if test="${banner?.img1!=null}">
	        	<li>
	        	 <g:if test="${banner?.link1!=null && str!="pc"}">
	              <a href="${banner?.link1}">
	              </g:if>
	        		<span style="background-image:url(/scfire/project/imgRead?img=${banner.img1})"></span>
	        		<g:if test="${banner?.link1!=null && str!="pc"}">
	              </a>
	              </g:if>
	              </li>
	        	</g:if>
	            <g:if test="${banner?.img2!=null}">
	            <li>
	              <g:if test="${banner?.link2!=null && str!="pc"}">
	              <a href="${banner?.link2}">
	              </g:if>
	        		<span style="background-image:url(/scfire/project/imgRead?img=${banner.img2})"></span>
	        		<g:if test="${banner?.link2!=null && str!="pc"}">
	                </a>
	                </g:if></li>
	        	</g:if>
	        	<g:if test="${banner?.img3!=null}">
	        	<li>
	        	 <g:if test="${banner?.link3!=null && str!="pc"}">
	              <a href="${banner?.link3}">
	              </g:if>
	        		<span style="background-image:url(/scfire/project/imgRead?img=${banner.img3})"></span>
	        		<g:if test="${banner?.link3!=null && str!="pc"}">
	                </a>
	                </g:if></li>
	        	</g:if>
	        	 <g:if test="${banner?.img4!=null}">
	            <li>
	              <g:if test="${banner?.link4!=null && str!="pc"}">
	              <a href="${banner?.link4}">
	              </g:if>
	        		<span style="background-image:url(/scfire/project/imgRead?img=${banner.img4})"></span>
	        		<g:if test="${banner?.link4!=null && str!="pc"}">
	                </a>
	                </g:if></li>
	        	</g:if>
	        	 <g:if test="${banner?.img5!=null}">
	            <li>
	              <g:if test="${banner?.link5!=null && str!="pc"}">
	              <a href="${banner?.link5}">
	              </g:if>
	              <span style="background-image:url(/scfire/project/imgRead?img=${banner.img5})"></span>
	        		<g:if test="${banner?.link5!=null && str!="pc"}">
	                </a>
	                </g:if></li>
	        	</g:if>
	        </ul>
	    </div>
	    <div class="p-title">爱心池<a href="/scfire/project/fundPoolList" class="btn">更多&nbsp;></a></div>
        <ul class="fp-list-tiled ui-grid-trisect" id="showpooldata">
           
        </ul>
	
	    <div class="p-title">精选推荐
		    <div class="search">  
			    <div class="txt">
			        <img src="http://mat1.gtimg.com/gongyi/m/wx/search.png">查询公益项目
			    </div>         
			</div>
	    </div>
	    <ul class="p-list" id="showdata"><%--	
	   		 <g:each in="${projects}" var="${project}">
	   		 <li>
               <a href="/scfire/project/projectDetail?projectid=${project.id}">
                    <div class="top" style="background-image:url(/scfire/project/imgRead?img=${project.img})">
                        <div class="h3-box"><h3>${project.name}</h3></div>
                        <div class="ui-progress">
                            <span style="width:${project.progress}%"></span>
                        </div>
                        <g:if test="${project.verified=='pass'}">
		                	<div class="status">募集中</div>
		                </g:if>                
		                <g:elseif test="${project.verified=='execute'}">
		                	<div class="status yellow">已筹满</div>
		                </g:elseif>
		                <g:elseif test="${project.verified=='expired'}">
		                	<div class="status">已过期</div>
		                </g:elseif>
		                <g:elseif test="${project.verified=='over'}">
		                	<div class="status">已结束</div>
		                </g:elseif>
                    </div>
                    <div class="bottom">
                        <div class="infos">
                            <div class="infos-l">共<span class="num">${project?.donates?.size()}</span>份爱心</div>
                            <div class="infos-r">已筹<span class="num"><g:formatNumber number="${project.amount - project.rest}" format="0.00"/></span>元</div>
                        </div>
                        <p>${project.description}</p>
                    </div>
                </a>
            </li>
	   		</g:each>
	   		
              	<li id="remove"><a href='javascript:;' class='btn-more' id='week' onclick="window.location.href='/scfire/project/projectList?recommand=donate'">点击查看项目</a></li>
              	--%>
	       	 
	    </ul>
    </div>
	<script type="text/javascript">
	var c=0 
	var next=0
	var t
	(function() {
        var slider = new fz.Scroll('.ui-slider', {
            role: 'slider',
            indicator: true,
            autoplay: true,
            interval: 2500
        });
		timedCount();
        slider.on('beforeScrollStart', function(from, to) {
           // console.log(from, to);
        });

        slider.on('scrollEnd', function(curPage) {
          //  console.log(curPage);
        });
        showPool();
    })();
	
	function timedCount() 
	{ 
	c=c+1 
	t=setTimeout("timedCount()",1000)
    var cnum=$("#nums").val();
	var count=cnum+"";
	if(count.length<7){
		var nums=7-count.length;
		var i=0;
		for(i=0;i<nums;i++){
			count="0"+count;
			}
		}
	if(c==3){
		if(next==0){
			$("span li").each(function(index, el) {
		        var indnum=count.charAt(index)*25;
 				$("span li").eq(index).css({
 	 				"background-position":"0 -"+indnum+"px",
 	 				});
		});	
			}
		}
	if(c==30){
		c=0;
		next++;
		if(next<4){
			$.ajax({  
	            type:'get',  
	            dataType:'json',
	            url:'/scfire/index/getCountsJson?format=json',         
	            success:function(data){
	               if(data.length<=0){
		               }else{
		            	   $("span li").each(function(index, el) {
		        				var count=data[0].counts+"";
		        				if(count.length<7){
		        					var nums=7-count.length;
		        					var i=0;
		        					for(i=0;i<nums;i++){
		        						count="0"+count;
		        						}
		        					}
		        				$("span li").each(function(index, el) {
		        			        var indnum=count.charAt(index)*25;
		        			        if(index>2){
		        			        	$("span li").eq(index).css({
			        	 	 				"background-position":"0 -"+indnum+"px",
			        	 	 				});
			        			        }
		        			});	
		       		  });	
			               
			               }
	          	 
	            },  
	            complete:function(){},
	      });  
			}
		if(next==4){
			stopCount();
			}
		
		}
	} 
	function stopCount() 
	{ 
	clearTimeout(t) 
	} 
	 //异步加载首页内容信息
	function showPool(){
		
        var html="";
        var el;
    	$.ajax({  
            type:'get',  
            dataType:'json',
            url:'/scfire/index/indexPoolJSON?format=json',         
            beforeSend:function(){
	            	el=$.loading({
	    		        content:"加载中...",
	    		    });
                },
                
            success:function(data){
            	var flag =IsPC();
          	  $.each(data,function(i,funpool){
          		
          		html+="<li>"
       			if(flag==true){
       				html+="<a href='/scfire/project/fundpooldetailPC?fundPoolid="+funpool.id+"'>"
       			}
       			else{
       				html+="<a href='/scfire/project/fundpooldetail?fundPoolid="+funpool.id+"'>"
           			}
          		html+="<div class='ui-grid-trisect-img'>"
          		html+="<span style='background-image:url(/scfire/project/imgRead?img="+funpool.img+")'>"
<%--          		html+="<span>"+funpool.type+"</span>"--%>
          		html+="<p class='ui-nowrap'>"+funpool.totalCount+"元</p>"
          		html+="</span>"
          		html+="</div>"
          		html+="<div>"
          		html+="<h5 class='ui-nowrap'>"+csubstr(funpool.name,6)+"</p>"
          		html+="</div>"
          		html+="</a>"	
          		html+=" </li>"	
          		
          	  });
          	 $("#showpooldata").append(html);
          	 el.loading("hide");
            },  
            complete:function(){},
            error:function(data){
            	el.loading("hide");
            	el=$.loading({
    		        content:"加载失败,请刷新重试",
    		    });
            }
           
      });  
    }
    //异步加载首页内容信息
    showProject();
	function showProject(){		
        var html="";
        var el;
    	$.ajax({  
            type:'get',  
            dataType:'json',
            url:'/scfire/index/indexJSON?format=json',         
            beforeSend:function(){
	            	el=$.loading({
	    		        content:"加载中...",
	    		    });
                },
                
            success:function(data){
            	var flag =IsPC(); 
          	  $.each(data,function(i,project){
              	  if(project.verified!='wait'&&project.verified!='draft'&&project.verified!='refuse'&&project.verified!='modify'){
                  	  
          		html+="<li>"
              		if(flag==true){
              			html+="<a href='/scfire/project/projectDetailPC?projectid="+project.id+"'>"
                  		}
              		else{
               			html+="<a href='/scfire/project/projectDetail?projectid="+project.id+"'>"
                   		}
          		
          		html+="<div class='top' style='background-image:url(/scfire/project/imgRead?img="+project.img+")'>"

          		html+="<div class='h3-box'><h3>"+project.name+"</h3></div>"
          		html+="<div class='ui-progress'>"
          		html+="<span style='width:"+project.progress+"%'></span>"
          		html+="</div>"

          		if(project.verified=="pass"){
          			html+="<div class='status'>募集中</div>"
          		}else if(project.verified=="execute"||project.verified=="expired"){
          			html+="<div class='status yellow'>已筹完</div>"
              	}else if(project.verified=="over"){
          			html+="<div class='status yellow'>已结项</div>"
              	}else if(project.verified=="doing"){
          			html+="<div class='status yellow'>执行中</div>"
              	}
              	
              	html+="</div>"  		
          		html+="<div class='bottom'>"	
          		html+="<div class='infos'>"
          		html+="<div class='infos-l'>共<span class='num'>"+project.donatenum+"</span>份爱心</div>"
          		html+="<div class='infos-r'>已筹<span class='num'>"+project.donatemoney+"</span>元</div>"
          		html+="</div>"
          		html+="<p>"+project.description+"</p>"
          		html+="</div>"
          		html+="</a>"
          		html+="</li>"
              	  }
          	  });
   			 html+="<li id='remove'><a href='javascript:;' class='btn-more' id='week' onclick=\"window.location.href='/scfire/project/projectListsign'\">查看全部项目</a></li>"
          	 $("#showdata").append(html);
          	 el.loading("hide");
          	 
            },  
            complete:function(){},
            error:function(data){
            	el.loading("hide");
            	el=$.loading({
    		        content:"加载失败,请刷新重试",
    		    });
            }
           
      });  
    }
    function csubstr(str,len){
   	 if(str.length>7){
       	
   	  return str.substring(0,len)+"...";
   	 }else{
   	  return str;
   	 }
   	}
 	$('.search').click(function(){
   		window.location.href='/scfire/project/projectsearch';
   	   	});

     var flag = IsPC();
     if(flag==true){
    	 $("#index").attr("href","/scfire/index/pc_index/");
         	$("#project").remove();
			$("#center").remove();
         }
	
	</script>

</body>
</html>